using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Park.Net.Model;
using Park.Net.EFCoreEnv;
using Park.Net.IRepository;
using Park.Net.Repository;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;

namespace Park.Net.IRepository
{
    public class RentRepository : BaseRepository<Rent>,IRentRepository
    { 
        private readonly ParkDbContext  _context;

        public RentRepository(ParkDbContext db) : base(db)
        {
            ParkDb = db;
            _context=db;
        }


        public async override Task<List<Rent>> FindAllAsync()
        {
            return await _context.Rent.ToListAsync();
        }

        public async override Task<List<Rent>> FindManyAsync(Expression<Func<Rent, bool>> exp)
        {
            return await _context.Rent.Where(exp).ToListAsync();
        }

        public async override Task<Rent> FindOneAsync(Expression<Func<Rent, bool>> exp)
        {
            return await _context.Rent.FirstOrDefaultAsync(exp);
        }

        public override async Task<Rent> FindOneAsync(int id)
        {
            return await _context.Rent.FirstOrDefaultAsync(art=>art.ID == id);
        }
    }
}
